using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Tigger : MonoBehaviour
{
    // 需要隐藏/显示的目标物体，在Inspector中拖拽赋值
    public GameObject targetObject;
    

    // 检测碰撞的角色标签
    public string playerTag = "Player";

    // 当Player进入触发器时调用
    private void OnTriggerEnter(Collider other)
    {
        // 判断碰撞体是否为Player
        if (other.CompareTag(playerTag) && targetObject != null)
        {
            // 切换目标物体的激活状态
            targetObject.SetActive(!targetObject.activeSelf);
        }
    }
}
